<?php
namespace Biz\model\activity;
use Doraemon\pockets\datebase\BaseDbModel;

class NewCommerExclusiveSku extends BaseDbModel
{

	const _CONFIG_FILE_ = 'db_shop';

	const _CONFIG_SELECT_ = 'db_activity';

	const _DATABASE_ = 'shop_activity';

	const _TABLE_NAME = 'newcommer_exclusive_sku';

	const STATUS_NORMAL = 1;

	const STATUS_NO_PRICE = 2; // 中间态 未更新活动价状态

	const STATUS_DELETE = 9;

	public static function insertData(array $datas, $adminUid)
	{
		$insertData = [];
		foreach ($datas as $data) {
			$insertData[] = [
				'goods_id' => $data['goods_id'],
				'exclusive_id' => $data['exclusive_id'],
				'sku_id' => $data['sku_id'],
				'admin_uid' => $adminUid,
				'start_time' => $data['start_time'],
				'end_time' => $data['end_time'],
				'add_time' => date("Y-m-d H:i:s"),
				'edit_time' => date("Y-m-d H:i:s"),
				'status' => self::STATUS_NO_PRICE
			];
		}
		$results = self::insert($insertData);
		return $results -> rowCount();
	}

	public static function getInfos($id, $goodsId, $isMaster = false)
	{
		$funName = 'select';
		if ($isMaster) {
			$funName = 'select_master';
		}
		return self::$funName('*', [
			'exclusive_id' => $id,
			'goods_id' => $goodsId,
			'status' => [
				self::STATUS_NORMAL,
				self::STATUS_NO_PRICE
			]
		]);
	}

	public static function infoList($page, $pagesize)
	{
		$infos = self::select('*', [
			'status' => [
				self::STATUS_NORMAL,
				self::STATUS_NO_PRICE
			],
			'ORDER' => ['end_time'=> 'DESC'],
			'LIMIT' => [($page - 1) * $pagesize, $pagesize]
		]);

		return $infos;

	}












}